//
//  HeroTableViewCell.m
//  LOL视频播放
//
//  Created by 花花蔡 on 2016/12/14.
//  Copyright © 2016年 com.HuaHuaCai. All rights reserved.
//

#import "HeroTableViewCell.h"
#import "Public.h"
#import "UIImageView+WebCache.h"
@interface HeroTableViewCell ()

//头像
@property(nonatomic,strong) UIImageView *videoImageView;
//标题
@property(nonatomic,strong) UILabel *videoTitleLabel;

//时间
@property(nonatomic,strong) UILabel *videoTimeLabel;

//视频数量
@property(nonatomic,strong) UILabel *videoCountLabel;


@end

@implementation HeroTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(HeroModel *)model {
    [_videoImageView sd_setImageWithURL:[NSURL URLWithString:model.Pic] placeholderImage:[UIImage imageNamed:@"占位图"]];
    _videoTitleLabel.text = [NSString stringWithFormat:@"%@   %@",model.NickName,model.CName];
    _videoCountLabel.text = [NSString stringWithFormat:@"视频:%@",model.VideoCount];
    _videoTimeLabel.text = [model.PubTime stringByReplacingOccurrencesOfString:@"T" withString:@" "];
}

+ (instancetype)loadCellWithTableView:(UITableView *)tableView {
    
    HeroTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HeroCell"];
    
    if (!cell) {
        cell = [[HeroTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"HeroCell"];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createCell];
    }
    return self;
}

- (void)createCell {
    //图片框
    self.videoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(6*KWidth_ScaleW, 6*KWidth_ScaleW, 98*KWidth_ScaleW, 98*KWidth_ScaleW)];
    //切圆角
    self.videoImageView.layer.cornerRadius = 7;
    self.videoImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.videoImageView];
    
    //标题
    _videoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(110*KWidth_ScaleW, 0, screen_width - 146*KWidth_ScaleW, 67*KWidth_ScaleW)];
    _videoTitleLabel.font = [UIFont systemFontOfSize:21*KWidth_ScaleW];
    _videoTitleLabel.numberOfLines = 0;
    _videoTitleLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:_videoTitleLabel];
    
    //时间
    _videoTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(110*KWidth_ScaleW, 86*KWidth_ScaleW,screen_width - 240*KWidth_ScaleW, 18*KWidth_ScaleW)];
    _videoTimeLabel.font = [UIFont systemFontOfSize:15*KWidth_ScaleW];
    _videoTimeLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_videoTimeLabel];
    
    //视频
    _videoCountLabel = [[UILabel alloc] initWithFrame:CGRectMake( screen_width - 112 * KWidth_ScaleW, 86*KWidth_ScaleW, 104*KWidth_ScaleW, 18*KWidth_ScaleW)];
    _videoCountLabel.font = [UIFont systemFontOfSize:15 * KWidth_ScaleW];
    _videoCountLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_videoCountLabel];
    
}

@end
